package com.controller;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.bean.About;
import com.bean.Admin;
import com.bean.Application;
import com.bean.CaseList;
import com.bean.Honor;
import com.bean.IndexImg;
import com.bean.JiShu;
import com.bean.RenLi;
import com.bean.SecondTitle;
import com.bean.Title;
import com.bean.TouZhi;
import com.bean.XiaZai;
import com.bean.XinWen;
import com.bean.XuQiu;
import com.bean.ZhaoPin;
import com.biz.AboutService;
import com.biz.AdminService;
import com.biz.ApplicationService;
import com.biz.CaseListService;
import com.biz.HonorService;
import com.biz.IndexImgService;
import com.biz.JiShuService;
import com.biz.RenLiService;
import com.biz.SecondTitleService;
import com.biz.TitleService;
import com.biz.TouZhiService;
import com.biz.XiaZaiService;
import com.biz.XinWenService;
import com.biz.XuQiuService;
import com.biz.ZhaoPinService;
import com.sun.org.apache.commons.digester.rss.Image;
import com.util.Messages;
import com.util.WebUtil;

/*import com.sun.imageio.plugins.wbmp.WBMPImageReader;*/



@Controller
@RequestMapping(value = "/admin")
@Scope("prototype")
public class maincontroller {
	@Resource
	private AdminService adminService;

	@Resource
	private AboutService aboutService;

	@Resource
	private XinWenService xinwenService;

	@Resource
	private XuQiuService xuQiuService;

	@Resource
	private TouZhiService touZhiService;

	@Resource
	private ZhaoPinService zhaoPinService;

	@Resource
	private RenLiService renliService;

	@Resource
	private JiShuService jiShuService;

	@Resource
	private HonorService honorService;

	@Resource
	private CaseListService caseListService;

	@Resource
	private ApplicationService appService;

	@Resource
	private XiaZaiService xiaZaiService;

	@Resource
	private TitleService titleService;

	@Resource
	private SecondTitleService secondTitleService;

	@Resource
	private IndexImgService imgService;

	/**
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/login")
	public String login(Model model,HttpServletRequest request, HttpServletResponse response) {
		return "admin/login";
	}

	@RequestMapping(value = "/log")
	@ResponseBody
	public Object log(Model model,HttpServletRequest request, HttpServletResponse response,Admin admin) {
		Admin  user = adminService.getEntityByProperty(" username=:username ",WebUtil.TFUFT8(admin.getUsername()));
		if(user==null){
			return WebUtil.getMap(new String[]{"success","message"},new Object[]{false,"用户不存在"});
		}
		if(!user.getPassword().equals(admin.getPassword())){
			return WebUtil.getMap(new String[]{"success","message"},new Object[]{false,"密码错误"});
		}
		request.getSession().setAttribute("User", user);
		return WebUtil.getMap(new String[]{"success","message","url"},new Object[]{true,"登录成功","../admin/index"});
	}

	@RequestMapping("/huiyuan")
	public String huiyuanlist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		List<Admin> list =adminService.getEntityAll();
		model.addAttribute("user", user);
		model.addAttribute("hylist", list);
		model.addAttribute("page", "huiyuanlist.jsp");
		return "admin/index";
	}
	@RequestMapping("/goaddhy")
	public String goaddhuiyuan(Model model,HttpServletRequest request,HttpServletResponse response ){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		model.addAttribute("page", "addhuiyuan.jsp");
		return "admin/index";
	}
	@RequestMapping("/addhy")
	public String addhuiyuan(Model model,HttpServletRequest request,HttpServletResponse response,Admin admin ){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}

		/*StringBuilder str=new StringBuilder();//定义变长字符串
		Random random=new Random();
		//随机生成数字，并添加到字符串
		for(int i=0;i<8;i++){
			str.append(random.nextInt(10));
		}
		//将字符串转换为数字并输出
		//int num=Integer.parseInt(str.toString());
		 */		
		 admin.setPassword(WebUtil.TFUFT8(admin.getPassword()));
		 admin.setUsername(WebUtil.TFUFT8(admin.getUsername()));
		 admin.setMag(admin.getMag());
		 adminService.addEntity(admin);
		 return "redirect:huiyuan";
	}
	@RequestMapping("/delhy")
	public String delAdmin(Model model,HttpServletRequest request,HttpServletResponse response,Admin Admin ){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id =Integer.parseInt(request.getParameter("id"));
		adminService.delete(" id=:id ", id);
		return "redirect:huiyuan";
	}

	@RequestMapping("/index")
	public String order(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		model.addAttribute("page", "success.jsp");
		return "admin/index";
	}

	@RequestMapping("/img")
	public String imglist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		List<IndexImg> list =imgService.getAllByProperty(" type=:type ", type);
		model.addAttribute("fclist", list);
		if(type == 1){
			model.addAttribute("page", "indexImg.jsp");
		}else if(type == 2){
			model.addAttribute("page", "cpImg.jsp");
		}else if(type == 3){
			model.addAttribute("page", "contact.jsp");
		}

		return "admin/index";
	}
	@RequestMapping("/goaddin")
	public String goaddimg(Model model,HttpServletRequest request,HttpServletResponse response ){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			model.addAttribute("page", "addindex.jsp");
		}else if(type == 2){
			model.addAttribute("page", "addcpindex.jsp");
		}else if(type == 3){
			model.addAttribute("page", "addcontact.jsp");
		}

		return "admin/index";
	}
	@RequestMapping("/addin")
	public String addimg(Model model,HttpServletRequest request,HttpServletResponse response,IndexImg fengcai ){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			fengcai.setType(type);
			fengcai.setPublish(0);
			imgService.addEntity(fengcai);
			return "redirect:img?type=1";
		}else if(type == 2){
			fengcai.setCpname(WebUtil.TFUFT8(fengcai.getCpname()));
			fengcai.setUrl(WebUtil.TFUFT8(fengcai.getUrl()));
			fengcai.setType(type);
			fengcai.setPublish(0);
			imgService.addEntity(fengcai);
			return "redirect:img?type=2";
		}else if(type == 3){
			fengcai.setAdress(WebUtil.TFUFT8(fengcai.getAdress()));
			fengcai.setPhone(WebUtil.TFUFT8(fengcai.getPhone()));
			fengcai.setChuanzhen(WebUtil.TFUFT8(fengcai.getChuanzhen()));
			fengcai.setEmail(WebUtil.TFUFT8(fengcai.getEmail()));
			fengcai.setYoubian(WebUtil.TFUFT8(fengcai.getYoubian()));
			fengcai.setType(type);
			fengcai.setPublish(0);
			imgService.addEntity(fengcai);
			return "redirect:img?type=3";
		}else{
			return "redirect:img?type=1";
		}
	}
	@RequestMapping("/delin")
	public String delimg(Model model,HttpServletRequest request,HttpServletResponse response,IndexImg fengcai ){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id =Integer.parseInt(request.getParameter("id"));
		imgService.delete(" id=:id ", id);
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			return "redirect:img?type=1";
		}else if(type == 2){
			return "redirect:img?type=2";
		}else if(type == 3){
			return "redirect:img?type=3";
		}else{
			return "redirect:img?type=1";
		}

	}

	@RequestMapping("/goupdatein")
	public String goupdatet(Model model,HttpServletRequest request,HttpServletResponse response,IndexImg tongzhi){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		IndexImg tz = imgService.getEntityByProperty(" id=:id ", id);
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			model.addAttribute("picinfo",tz);
			model.addAttribute("page", "updateindex1.jsp");
		}else if(type == 2){
			model.addAttribute("picinfo",tz);
			model.addAttribute("page", "updateindex2.jsp");
		}else if(type == 3){
			model.addAttribute("picinfo",tz);
			model.addAttribute("page", "updateindex3.jsp");
		}

		return "admin/index";
	}
	//����֪ͨ
	@RequestMapping("/updatein")
	public String updateti(Model model,HttpServletRequest request,HttpServletResponse response,IndexImg tongzhi){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			tongzhi.setType(type);
			tongzhi.setPublish(0);
			imgService.update(tongzhi);
			return "redirect:img?type=1";
		}else if(type == 2){
			tongzhi.setCpname(WebUtil.TFUFT8(tongzhi.getCpname()));
			tongzhi.setUrl(WebUtil.TFUFT8(tongzhi.getUrl()));
			tongzhi.setType(type);
			tongzhi.setPublish(0);
			imgService.update(tongzhi);
			return "redirect:img?type=2";
		}else if(type == 3){
			tongzhi.setAdress(WebUtil.TFUFT8(tongzhi.getAdress()));
			tongzhi.setPhone(WebUtil.TFUFT8(tongzhi.getPhone()));
			tongzhi.setChuanzhen(WebUtil.TFUFT8(tongzhi.getChuanzhen()));
			tongzhi.setEmail(WebUtil.TFUFT8(tongzhi.getEmail()));
			tongzhi.setYoubian(WebUtil.TFUFT8(tongzhi.getYoubian()));
			tongzhi.setType(type);
			tongzhi.setPublish(0);
			imgService.update(tongzhi);
			return "redirect:img?type=3";
		}else{
			return "redirect:img?type=1";
		}

	}

	@RequestMapping("/pubin")
	public String publishin(Model model,HttpServletRequest request,HttpServletResponse response,IndexImg fengcai){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		Integer type=Integer.parseInt(request.getParameter("type"));
		IndexImg fc = imgService.getEntityByProperty(" id=:id ", id);
		fc.setId(id);
		fc.setPublish(1);
		fc.setType(type);
		if(type == 1){
			imgService.update(fc);
			return "redirect:img?type=1";
		}else if(type == 2){
			fc.setCpname(fc.getCpname());
			fc.setUrl(WebUtil.TFUFT8(fc.getUrl()));
			imgService.update(fc);
			return "redirect:img?type=2";
		}else if(type == 3){
			fc.setAdress(fc.getAdress());
			fc.setPhone(WebUtil.TFUFT8(fc.getPhone()));
			fc.setChuanzhen(WebUtil.TFUFT8(fc.getChuanzhen()));
			fc.setEmail(WebUtil.TFUFT8(fc.getEmail()));
			fc.setYoubian(WebUtil.TFUFT8(fc.getYoubian()));
			imgService.update(fc);
			return "redirect:img?type=3";
		}else{
			return "redirect:img?type=1";
		}
	}


	/*@RequestMapping("/first")
	public String titlelist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		List<Title> lists =titleService.getAllByProperty(" 1=:id order by sort", 1);
		model.addAttribute("gklist", lists);
		model.addAttribute("page", "secondtitlelist.jsp");


		return "admin/index";
	}*/
	@RequestMapping("/goaddf")
	public String goaddfirst(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		model.addAttribute("page", "addtitle.jsp");
		return "admin/index";
	}
	@RequestMapping("/addfirst")
	public String addtitlt(Model model,HttpServletRequest request,HttpServletResponse response,Title about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		about.setTitle(WebUtil.TFUFT8(about.getTitle()));
		about.setUrl(WebUtil.TFUFT8(about.getUrl()));
		about.setSort(about.getSort());
		about.setPublish(0);
		titleService.addEntity(about);
		return "redirect:second";
	}
	@RequestMapping("/delf")
	public String delfirst(Model model,HttpServletRequest request,HttpServletResponse response,Title about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id = Integer.parseInt(request.getParameter("id"));
		List<SecondTitle> list = secondTitleService.getAllByProperty(" tit_id=:tit_id ", id);
		if(list != null){
			for(int i=0;i<list.size();i++){
				secondTitleService.delete(" tit_id=:tit_id ", list.get(i).getTit());
			}
		}

		titleService.delete(" id=:id ", id);
		return "redirect:second";
	}

	@RequestMapping("/goupdatef")
	public String goupdatefirst(Model model,HttpServletRequest request,HttpServletResponse response,Title about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		Title gk = titleService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("gk",gk);
		model.addAttribute("page", "updatetitle.jsp");
		return "admin/index";
	}
	//���»
	@RequestMapping("/updatef")
	public String updatetitle(Model model,HttpServletRequest request,HttpServletResponse response,Title about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		about.setTitle(WebUtil.TFUFT8(about.getTitle()));
		about.setUrl(WebUtil.TFUFT8(about.getUrl()));
		about.setSort(about.getSort());
		about.setPublish(0);
		titleService.update(about);
		return "redirect:second";
	}
	//�����
	@RequestMapping("/pubf")
	public String publishf(Model model,HttpServletRequest request,HttpServletResponse response,Title about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		Title gk = titleService.getEntityByProperty(" id=:id ", id);
		about.setId(id);
		about.setUrl(gk.getUrl());
		about.setTitle(gk.getTitle());
		about.setSort(gk.getSort());
		about.setPublish(1);
		titleService.update(about);
		return "redirect:second";
	}

	@RequestMapping("/second")
	public String sectitlelist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		List<Title> list =titleService.getAllByProperty(" 1=:id order by sort", 1);
		model.addAttribute("flist", list);
		List<SecondTitle> lists =secondTitleService.getAllByProperty(" 1=:id", 1);
		model.addAttribute("gklist", lists);
		model.addAttribute("page", "secondtitlelist.jsp");


		return "admin/index";
	}
	@RequestMapping("/goadds")
	public String goaddsecond(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		model.addAttribute("id", request.getParameter("id"));
		model.addAttribute("page", "addsecondtitle.jsp");
		return "admin/index";
	}
	@RequestMapping("/addsec")
	public String addsectitlt(Model model,HttpServletRequest request,HttpServletResponse response,SecondTitle about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer tid = Integer.parseInt(request.getParameter("tid"));
		Title title = titleService.getEntityByProperty(" id=:id ", tid);
		about.setTitle(WebUtil.TFUFT8(about.getTitle()));
		about.setUrl(WebUtil.TFUFT8(about.getUrl()));
		about.setTit(title);
		about.setSort(about.getSort());
		about.setPublish(0);
		secondTitleService.addEntity(about);
		return "redirect:second";
	}
	@RequestMapping("/dels")
	public String dels(Model model,HttpServletRequest request,HttpServletResponse response,SecondTitle about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id = Integer.parseInt(request.getParameter("id"));
		secondTitleService.delete(" id=:id ", id);
		return "redirect:second";
	}

	@RequestMapping("/goupdates")
	public String goupdatest(Model model,HttpServletRequest request,HttpServletResponse response,SecondTitle about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		SecondTitle gk = secondTitleService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("gk",gk);
		model.addAttribute("page", "updatesectitle.jsp");
		return "admin/index";
	}
	//���»
	@RequestMapping("/updates")
	public String updatestitle(Model model,HttpServletRequest request,HttpServletResponse response,SecondTitle about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		String tit = request.getParameter("tit");
		Title title = titleService.getEntityByProperty(" tit=:tit ", tit);
		about.setTitle(WebUtil.TFUFT8(about.getTitle()));
		about.setUrl(WebUtil.TFUFT8(about.getUrl()));
		about.setTit(title);
		about.setSort(about.getSort());
		about.setPublish(0);
		secondTitleService.update(about);
		return "redirect:second";
	}
	//�����
	@RequestMapping("/pubs")
	public String publishs(Model model,HttpServletRequest request,HttpServletResponse response,SecondTitle about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		SecondTitle gk = secondTitleService.getEntityByProperty(" id=:id ", id);
		about.setId(id);
		about.setUrl(gk.getUrl());
		about.setTitle(gk.getTitle());
		about.setTit(gk.getTit());
		about.setSort(about.getSort());
		about.setPublish(1);
		secondTitleService.update(about);
		model.addAttribute("page", "secondtitlelist.jsp");
		return "redirect:second";
	}

	//��ȡ���л
	@RequestMapping("/gaikuo")
	public String gaikuolist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		List<About> lists = null;
		if(type == 1){
			lists =aboutService.getAllByProperty(" type=:type  order by time", "公司概况");
			model.addAttribute("gklist", lists);
			model.addAttribute("page", "gaikuolist1.jsp");
		}else if(type == 2){
			lists =aboutService.getAllByProperty(" type=:type  order by time", "分支机构");
			model.addAttribute("gklist", lists);
			model.addAttribute("page", "gaikuolist2.jsp");
		}else if(type == 3){
			lists =aboutService.getAllByProperty(" type=:type  order by time", "公司大事记");
			model.addAttribute("gklist", lists);
			model.addAttribute("page", "gaikuolist3.jsp");
		}

		return "admin/index";
	}
	//�����
	@RequestMapping("/gkinfo")
	public String gaikuoinfo(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		Integer id=Integer.parseInt(request.getParameter("id")); 
		About gaiKuo= aboutService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("gk", gaiKuo);
		model.addAttribute("page", "gaikuoinfo.jsp");
		return "admin/index";
	}
	//��ӻ
	@RequestMapping("/addgk")
	public String addgaikuo(Model model,HttpServletRequest request,HttpServletResponse response,About about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			about.setType("公司概况");
		}else if(type == 2){
			about.setType("公司机构");
		}else if(type == 3){
			about.setType("公司大事记");
		}
		about.setContent(WebUtil.TFUFT8(about.getContent()));
		about.setTitle(WebUtil.TFUFT8(about.getTitle()));
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		about.setTime(WebUtil.TFUFT8(time));
		about.setPublish(0);
		aboutService.addEntity(about);
		return "redirect:gaikuo?type="+type;
	}	
	//ɾ��
	@RequestMapping("/delgk")
	public String delAbout(Model model,HttpServletRequest request,HttpServletResponse response,About about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		Integer id = Integer.parseInt(request.getParameter("id"));
		aboutService.delete(" id=:id ", id);
		return "redirect:gaikuo?type="+type;
	}
	//��ӻ
	@RequestMapping("/goaddgk")
	public String goaddAbout(Model model,HttpServletRequest request,HttpServletResponse response,About about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		model.addAttribute("page", "addgaikuo.jsp");
		return "admin/index";
	}	
	//���»
	@RequestMapping("/goupdategk")
	public String goupdateAbout(Model model,HttpServletRequest request,HttpServletResponse response,About about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		About gk = aboutService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("gk",gk);
		Integer type=Integer.parseInt(request.getParameter("types"));
		model.addAttribute("type", type);
		model.addAttribute("page", "updategaikuo.jsp");
		return "admin/index";
	}
	//���»
	@RequestMapping("/updategk")
	public String updateAbout(Model model,HttpServletRequest request,HttpServletResponse response,About about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			about.setType("公司概况");
		}else if(type == 2){
			about.setType("公司机构");
		}else if(type == 3){
			about.setType("公司大事记");
		}
		about.setContent(WebUtil.TFUFT8(about.getContent()));
		about.setTitle(WebUtil.TFUFT8(about.getTitle()));
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		about.setTime(WebUtil.TFUFT8(time));
		about.setPublish(0);
		aboutService.update(about);
		return "redirect:gkinfo?id="+about.getId();
	}
	//�����
	@RequestMapping("/pubgk")
	public String publish(Model model,HttpServletRequest request,HttpServletResponse response,About about){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		Integer type=Integer.parseInt(request.getParameter("type"));
		About gk = aboutService.getEntityByProperty(" id=:id ", id);
		about.setId(id);
		about.setTitle(gk.getTitle());
		about.setType(gk.getType());
		about.setContent(gk.getContent());
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		about.setTime(WebUtil.TFUFT8(time));
		about.setPublish(1);
		aboutService.update(about);
		model.addAttribute("page", "gaikuolist.jsp");
		return "redirect:gaikuo?type="+type;
	}

	//��ȡ����֪ͨ
	@RequestMapping("/tongzhi")
	public String tongzhilist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		List<XinWen> lists =xinwenService.getAllByProperty(" 1=:id  order by time", 1);
		model.addAttribute("tzlist", lists);
		model.addAttribute("page", "tongzhilist.jsp");
		return "admin/index";
	}
	//֪ͨ����
	@RequestMapping("/tzinfo")
	public String tongzhiinfo(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id")); 
		XinWen tz= xinwenService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("tz", tz);
		model.addAttribute("page", "tongzhiinfo.jsp");
		return "admin/index";
	}
	//���֪ͨ
	@RequestMapping("/addtz")
	public String addtongzhi(Model model,HttpServletRequest request,HttpServletResponse response,XinWen tz){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		tz.setContent(WebUtil.TFUFT8(tz.getContent()));
		tz.setTitle(WebUtil.TFUFT8(tz.getTitle()));
		tz.setTime(WebUtil.TFUFT8(time));
		tz.setPublish(0);
		xinwenService.addEntity(tz);
		return "redirect:tongzhi";
	}	
	//ɾ��֪ͨ
	@RequestMapping("/deltz")
	public String deltongzhi(Model model,HttpServletRequest request,HttpServletResponse response,XinWen tongzhi){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id = Integer.parseInt(request.getParameter("id"));
		xinwenService.delete(" id=:id ", id);
		return "redirect:tongzhi";
	}
	//���֪ͨ
	@RequestMapping("/goaddtz")
	public String goaddtongzhi(Model model,HttpServletRequest request,HttpServletResponse response,XinWen tongzhi){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		model.addAttribute("page", "addtongzhi.jsp");
		return "admin/index";
	}	
	//����֪ͨ
	@RequestMapping("/goupdatetz")
	public String goupdatetongzhi(Model model,HttpServletRequest request,HttpServletResponse response,XinWen tongzhi){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		XinWen tz = xinwenService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("tz",tz);
		model.addAttribute("page", "updatetongzhi.jsp");
		return "admin/index";
	}
	//����֪ͨ
	@RequestMapping("/updatetz")
	public String updatetongzhi(Model model,HttpServletRequest request,HttpServletResponse response,XinWen tongzhi){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		tongzhi.setContent(WebUtil.TFUFT8(tongzhi.getContent()));
		tongzhi.setTitle(WebUtil.TFUFT8(tongzhi.getTitle()));
		tongzhi.setTime(WebUtil.TFUFT8(time));
		tongzhi.setPublish(0);
		xinwenService.update(tongzhi);
		return "redirect:tzinfo?id="+tongzhi.getId();
	}
	//����֪ͨ
	@RequestMapping("/pubtz")
	public String publishs(Model model,HttpServletRequest request,HttpServletResponse response,XinWen tongzhi){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		XinWen tz = xinwenService.getEntityByProperty(" id=:id ", id);
		tongzhi.setId(id);
		tongzhi.setTitle(tz.getTitle());
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		tongzhi.setTime(WebUtil.TFUFT8(time));
		tongzhi.setContent(tz.getContent());
		tongzhi.setImgurl(tz.getImgurl());
		tongzhi.setPublish(1);
		xinwenService.update(tongzhi);
		model.addAttribute("page", "tongzhilist.jsp");
		return "redirect:tongzhi";
	}

	//��ȡ����֧����Ϣ
	@RequestMapping("/zhibu")
	public String zhibulist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		List<JiShu> lists = null;
		if(type == 1){
			lists =jiShuService.getAllByProperty(" type=:type  order by time", "科研机构");
		}else if(type == 2){
			lists =jiShuService.getAllByProperty(" type=:type  order by time", "科研成果");
		}else if(type == 3){
			lists =jiShuService.getAllByProperty(" type=:type  order by time", "研发动态");
		}else if(type == 4){
			lists =jiShuService.getAllByProperty(" type=:type  order by time", "典型案例");
		}
		model.addAttribute("type", type);
		model.addAttribute("zblist", lists);
		model.addAttribute("page", "zhibulist.jsp");
		return "admin/index";
	}
	//֧����Ϣ����
	@RequestMapping("/zbinfo")
	public String zhibuinfo(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id")); 
		JiShu zhibu= jiShuService.getEntityByProperty(" id=:id ", id);
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		model.addAttribute("zb", zhibu);
		model.addAttribute("page", "zhibuinfo.jsp");
		return "admin/index";
	}
	//���֧����Ϣ
	@RequestMapping("/addzb")
	public String addzhibu(Model model,HttpServletRequest request,HttpServletResponse response,JiShu zhibu){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			zhibu.setType("科研机构");
		}else if(type == 2){
			zhibu.setType("科研成果");
		}else if(type == 3){
			zhibu.setType("研发动态");
		}else if(type == 4){
			zhibu.setType("典型案例");
		}
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		zhibu.setContent(WebUtil.TFUFT8(zhibu.getContent()));
		zhibu.setTitle(WebUtil.TFUFT8(zhibu.getTitle()));
		zhibu.setTime(WebUtil.TFUFT8(time));
		zhibu.setPublish(0);
		jiShuService.addEntity(zhibu);
		return "redirect:zhibu?type="+type;
	}	
	//ɾ��֧����Ϣ
	@RequestMapping("/delzb")
	public String delzhibu(Model model,HttpServletRequest request,HttpServletResponse response,JiShu zhibu){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		Integer id = Integer.parseInt(request.getParameter("id"));
		jiShuService.delete(" id=:id ", id);
		return "redirect:zhibu?type="+type;
	}
	//���֧����Ϣ
	@RequestMapping("/goaddzb")
	public String goaddzhibu(Model model,HttpServletRequest request,HttpServletResponse response,JiShu zhibu){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		model.addAttribute("page", "addzhibu.jsp");
		return "admin/index";
	}	
	//����֧����Ϣ
	@RequestMapping("/goupdatezb")
	public String goupdatezhibu(Model model,HttpServletRequest request,HttpServletResponse response,JiShu zhibu){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		JiShu zb = jiShuService.getEntityByProperty(" id=:id ", id);
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		model.addAttribute("zb",zb);
		model.addAttribute("page", "updatezhibu.jsp");
		return "admin/index";
	}
	//����֧����Ϣ
	@RequestMapping("/updatezb")
	public String updatezhibu(Model model,HttpServletRequest request,HttpServletResponse response,JiShu zhibu){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		zhibu.setTime(WebUtil.TFUFT8(time));
		zhibu.setContent(WebUtil.TFUFT8(zhibu.getContent()));
		zhibu.setTitle(WebUtil.TFUFT8(zhibu.getTitle()));
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			zhibu.setType("科研机构");
		}else if(type == 2){
			zhibu.setType("科研成果");
		}else if(type == 3){
			zhibu.setType("研发动态");
		}else if(type == 4){
			zhibu.setType("典型案例");
		}
		zhibu.setPublish(0);
		jiShuService.update(zhibu);
		return "redirect:zbinfo?id="+zhibu.getId()+"&type="+type;
	}
	//����֧����Ϣ
	@RequestMapping("/pubzb")
	public String publish(Model model,HttpServletRequest request,HttpServletResponse response,JiShu zhibu){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		Integer id=Integer.parseInt(request.getParameter("id"));
		JiShu zb = jiShuService.getEntityByProperty(" id=:id ", id);
		zhibu.setId(id);
		zhibu.setTitle(zb.getTitle());
		zhibu.setType(zb.getType());
		zhibu.setContent(zb.getContent());
		zhibu.setPublish(1);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		zhibu.setTime(WebUtil.TFUFT8(time));
		jiShuService.update(zhibu);
		model.addAttribute("page", "zhibulist.jsp");
		return "redirect:zhibu?type="+type;
	}

	//��ȡ����ְ����Ϣ
	@RequestMapping("/zhineng")
	public String zhinenglist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		List<TouZhi> lists = null;
		if(type == 1){
			lists =touZhiService.getAllByProperty(" type=:type  order by time", "基本资料");
		}else if(type == 2){
			lists =touZhiService.getAllByProperty(" type=:type  order by time", "公司治理机构");
		}else if(type == 3){
			lists =touZhiService.getAllByProperty(" type=:type  order by time", "公司利润分配情况");
		}else if(type == 4){
			lists =touZhiService.getAllByProperty(" type=:type  order by time", "公司公告");
		}else if(type == 5){
			lists =touZhiService.getAllByProperty(" type=:type  order by time", "投资者交流");
		}
		model.addAttribute("type", type);
		model.addAttribute("znlist", lists);
		model.addAttribute("page", "zhinenglist.jsp");
		return "admin/index";
	}
	//ְ����Ϣ����
	@RequestMapping("/zninfo")
	public String zhinenginfo(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		Integer id=Integer.parseInt(request.getParameter("id")); 
		TouZhi zhineng= touZhiService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("zn", zhineng);
		model.addAttribute("page", "zhinenginfo.jsp");
		return "admin/index";
	}
	//���ְ����Ϣ
	@RequestMapping("/addzn")
	public String addzhineng(Model model,HttpServletRequest request,HttpServletResponse response,TouZhi zhineng){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			zhineng.setType("基本资料");
		}else if(type == 2){
			zhineng.setType("公司治理机构");
		}else if(type == 3){
			zhineng.setType("公司利润分配情况");
		}else if(type == 4){
			zhineng.setType("公司公告");
		}else if(type == 5){
			zhineng.setType("投资者交流");
		}
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		zhineng.setContent(WebUtil.TFUFT8(zhineng.getContent()));
		zhineng.setTitle(WebUtil.TFUFT8(zhineng.getTitle()));
		zhineng.setTime(WebUtil.TFUFT8(time));
		zhineng.setPublish(0);
		touZhiService.addEntity(zhineng);
		return "redirect:zhineng?type="+type;
	}	
	//ɾ��ְ����Ϣ
	@RequestMapping("/delzn")
	public String delzhineng(Model model,HttpServletRequest request,HttpServletResponse response,TouZhi zhineng){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		Integer id = Integer.parseInt(request.getParameter("id"));
		touZhiService.delete(" id=:id ", id);
		return "redirect:zhineng?type="+type;
	}
	//���ְ����Ϣ
	@RequestMapping("/goaddzn")
	public String goaddzhineng(Model model,HttpServletRequest request,HttpServletResponse response,TouZhi zhineng){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		model.addAttribute("page", "addzhineng.jsp");
		return "admin/index";
	}	
	//����ְ����Ϣ
	@RequestMapping("/goupdatezn")
	public String goupdatezhineng(Model model,HttpServletRequest request,HttpServletResponse response,TouZhi zhineng){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		Integer id=Integer.parseInt(request.getParameter("id"));
		TouZhi zn = touZhiService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("zn",zn);
		model.addAttribute("page", "updatezhineng.jsp");
		return "admin/index";
	}
	//����ְ����Ϣ
	@RequestMapping("/updatezn")
	public String updatezhineng(Model model,HttpServletRequest request,HttpServletResponse response,TouZhi zhineng){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		zhineng.setTime(WebUtil.TFUFT8(time));
		zhineng.setContent(WebUtil.TFUFT8(zhineng.getContent()));
		zhineng.setTitle(WebUtil.TFUFT8(zhineng.getTitle()));
		zhineng.setType(WebUtil.TFUFT8(zhineng.getType()));
		zhineng.setPublish(0);
		touZhiService.update(zhineng);
		return "redirect:zninfo?id="+zhineng.getId()+"&type="+type;
	}
	//����ְ����Ϣ
	@RequestMapping("/pubzn")
	public String publish(Model model,HttpServletRequest request,HttpServletResponse response,TouZhi zhineng){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		Integer id=Integer.parseInt(request.getParameter("id"));
		TouZhi zn = touZhiService.getEntityByProperty(" id=:id ", id);
		zhineng.setId(id);
		zhineng.setTitle(zn.getTitle());
		zhineng.setType(zn.getType());
		zhineng.setContent(zn.getContent());
		zhineng.setPublish(1);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		zhineng.setTime(WebUtil.TFUFT8(time));
		touZhiService.update(zhineng);
		model.addAttribute("page", "zhinenglist.jsp");
		return "redirect:zhineng?type="+type;
	}

	//��ȡ������֯��Ϣ
	@RequestMapping("/zuzhi")
	public String zuzhilist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		
		Integer type=Integer.parseInt(request.getParameter("type"));
		List<RenLi> lists = null;
		if(type == 1){
			lists =renliService.getAllByProperty(" type=:type  order by time", "欢迎辞");
		}else if(type == 2){
			lists =renliService.getAllByProperty(" type=:type  order by time", "人才战略");
		}else if(type == 3){
			lists =renliService.getAllByProperty(" type=:type  order by time", "人才机制");
		}
		model.addAttribute("type", type);
		model.addAttribute("zzlist", lists);
		model.addAttribute("page", "zuzhilist.jsp");


		return "admin/index";
	}
	//��֯��Ϣ����
	@RequestMapping("/zzinfo")
	public String zuzhiinfo(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		Integer id=Integer.parseInt(request.getParameter("id")); 
		RenLi zz= renliService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("zz", zz);
		model.addAttribute("page", "zuzhiinfo.jsp");
		return "admin/index";
	}
	//�����֯��Ϣ
	@RequestMapping("/addzz")
	public String addzuzhi(Model model,HttpServletRequest request,HttpServletResponse response,RenLi zz){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			zz.setType("欢迎辞");
		}else if(type == 2){
			zz.setType("人才战略");
		}else if(type == 3){
			zz.setType("人才机制");
		}
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		zz.setContent(WebUtil.TFUFT8(zz.getContent()));
		zz.setTitle(WebUtil.TFUFT8(zz.getTitle()));
		zz.setTime(WebUtil.TFUFT8(time));
		zz.setPublish(0);
		renliService.addEntity(zz);
		return "redirect:zuzhi?type="+type;
	}	
	//ɾ����֯��Ϣ
	@RequestMapping("/delzz")
	public String delzuzhi(Model model,HttpServletRequest request,HttpServletResponse response,RenLi zuzhi){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		Integer id = Integer.parseInt(request.getParameter("id"));
		renliService.delete(" id=:id ", id);
		return "redirect:zuzhi?type="+type;
	}
	//�����֯��Ϣ
	@RequestMapping("/goaddzz")
	public String goaddzuzhi(Model model,HttpServletRequest request,HttpServletResponse response,RenLi zuzhi){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		model.addAttribute("page", "addzuzhi.jsp");
		return "admin/index";
	}	
	//������֯��Ϣ
	@RequestMapping("/goupdatezz")
	public String goupdatezuzhi(Model model,HttpServletRequest request,HttpServletResponse response,RenLi zuzhi){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		Integer id=Integer.parseInt(request.getParameter("id"));
		RenLi zz = renliService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("zz",zz);
		model.addAttribute("page", "updatezuzhi.jsp");
		return "admin/index";
	}
	//������֯��Ϣ
	@RequestMapping("/updatezz")
	public String updatezuzhi(Model model,HttpServletRequest request,HttpServletResponse response,RenLi zuzhi){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			zuzhi.setType("欢迎辞");
		}else if(type == 2){
			zuzhi.setType("人才战略");
		}else if(type == 3){
			zuzhi.setType("人才机制");
		}
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		zuzhi.setContent(WebUtil.TFUFT8(zuzhi.getContent()));
		zuzhi.setTitle(WebUtil.TFUFT8(zuzhi.getTitle()));
		zuzhi.setTime(WebUtil.TFUFT8(time));
		zuzhi.setPublish(0);
		renliService.update(zuzhi);
		return "redirect:zzinfo?id="+zuzhi.getId()+"&type="+type;
	}
	//������֯��Ϣ
	@RequestMapping("/pubzz")
	public String publish(Model model,HttpServletRequest request,HttpServletResponse response,RenLi zuzhi){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		Integer id=Integer.parseInt(request.getParameter("id"));
		RenLi zz = renliService.getEntityByProperty(" id=:id ", id);
		zuzhi.setId(id);
		zuzhi.setTitle(zz.getTitle());
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		zuzhi.setTime(WebUtil.TFUFT8(time));
		zuzhi.setContent(zz.getContent());
		zuzhi.setPublish(1);
		renliService.update(zuzhi);
		model.addAttribute("page", "zuzhilist.jsp");
		return "redirect:zuzhi?type="+type;
	}

	//��ȡ����רί��Ϣ
	@RequestMapping("/zhuanwei")
	public String zhuanweilist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		List<XuQiu> lists =xuQiuService.getAllByProperty(" 1=:id  order by time", 1);
		model.addAttribute("zwlist", lists);
		model.addAttribute("page", "zhuanweilist.jsp");
		return "admin/index";
	}

	@RequestMapping("/zwinfo")
	public String zhuanweiinfo(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id")); 
		XuQiu zhuanwei= xuQiuService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("zw", zhuanwei);
		model.addAttribute("page", "zhuanweiinfo.jsp");
		return "admin/index";
	}

	@RequestMapping("/delzw")
	public String delzhuanwei(Model model,HttpServletRequest request,HttpServletResponse response,XuQiu zhuanwei){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id = Integer.parseInt(request.getParameter("id"));
		xuQiuService.delete(" id=:id ", id);
		return "redirect:zhuanwei";
	}

	@RequestMapping("/xinwen")
	public String xinwenlist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		List<CaseList> lists = null;
		if(type == 1){
			lists =caseListService.getAllByProperty(" type=:type  order by time", "油气勘探生产");
		}else if(type == 2){
			lists =caseListService.getAllByProperty(" type=:type  order by time", "多相计量产品与服务");
		}else if(type == 3){
			lists =caseListService.getAllByProperty(" type=:type  order by time", "压裂设备与服务");
		}else if(type == 4){
			lists =caseListService.getAllByProperty(" type=:type  order by time", "环保设备与服务");
		}
		model.addAttribute("type", type);
		model.addAttribute("xwlist", lists);
		model.addAttribute("page", "xinwenlist.jsp");
		return "admin/index";
	}
	//������Ϣ����
	@RequestMapping("/xwinfo")
	public String xinweninfo(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		Integer id=Integer.parseInt(request.getParameter("id")); 
		CaseList xinwen= caseListService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("xw", xinwen);
		model.addAttribute("page", "xinweninfo.jsp");
		return "admin/index";
	}
	//���������Ϣ
	@RequestMapping("/addxw")
	public String addxinwen(Model model,HttpServletRequest request,HttpServletResponse response,CaseList xinwen){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			xinwen.setType("油气勘探生产");
		}else if(type == 2){
			xinwen.setType("多相计量产品与服务");
		}else if(type == 3){
			xinwen.setType("压裂设备与服务");
		}else if(type == 4){
			xinwen.setType("环保设备与服务");
		}
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		xinwen.setContent(WebUtil.TFUFT8(xinwen.getContent()));
		xinwen.setTitle(WebUtil.TFUFT8(xinwen.getTitle()));
		xinwen.setTime(WebUtil.TFUFT8(time));
		xinwen.setPublish(0);
		caseListService.addEntity(xinwen);
		return "redirect:xinwen?type="+type;
	}	
	//ɾ��������Ϣ
	@RequestMapping("/delxw")
	public String delxinwen(Model model,HttpServletRequest request,HttpServletResponse response,CaseList xinwen){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		Integer id = Integer.parseInt(request.getParameter("id"));
		caseListService.delete(" id=:id ", id);
		return "redirect:xinwen?type="+type;
	}
	//���������Ϣ
	@RequestMapping("/goaddxw")
	public String goaddxinwen(Model model,HttpServletRequest request,HttpServletResponse response,CaseList xinwen){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		model.addAttribute("page", "addxinwen.jsp");
		return "admin/index";
	}	
	//����������Ϣ
	@RequestMapping("/goupdatexw")
	public String goupdatexinwen(Model model,HttpServletRequest request,HttpServletResponse response,CaseList xinwen){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
	
		Integer id=Integer.parseInt(request.getParameter("id"));
		CaseList xw = caseListService.getEntityByProperty(" id=:id ", id);
		Integer type=Integer.parseInt(request.getParameter("type"));
		model.addAttribute("type", type);
		model.addAttribute("xw",xw);
		model.addAttribute("page", "updatexinwen.jsp");
		return "admin/index";
	}
	//����������Ϣ
	@RequestMapping("/updatexw")
	public String updatexinwen(Model model,HttpServletRequest request,HttpServletResponse response,CaseList xinwen){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		if(type == 1){
			xinwen.setType("油气勘探生产");
		}else if(type == 2){
			xinwen.setType("多相计量产品与服务");
		}else if(type == 3){
			xinwen.setType("压裂设备与服务");
		}else if(type == 4){
			xinwen.setType("环保设备与服务");
		}
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		xinwen.setTime(WebUtil.TFUFT8(time));
		xinwen.setContent(WebUtil.TFUFT8(xinwen.getContent()));
		xinwen.setTitle(WebUtil.TFUFT8(xinwen.getTitle()));
		xinwen.setPublish(0);
		caseListService.update(xinwen);
		return "redirect:xwinfo?id="+xinwen.getId()+"&type="+type;
	}
	//����������Ϣ
	@RequestMapping("/pubxw")
	public String publishxw(Model model,HttpServletRequest request,HttpServletResponse response,CaseList xinwen){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer type=Integer.parseInt(request.getParameter("type"));
		Integer id=Integer.parseInt(request.getParameter("id"));
		CaseList xw = caseListService.getEntityByProperty(" id=:id ", id);
		xinwen.setId(id);
		xinwen.setTitle(xw.getTitle());
		xinwen.setType(xw.getType());
		xinwen.setContent(xw.getContent());
		xinwen.setPublish(1);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		xinwen.setTime(WebUtil.TFUFT8(time));
		caseListService.update(xinwen);
		model.addAttribute("page", "xinwenlist.jsp");
		return "redirect:xinwen?type="+type;
	}

	@RequestMapping("/fengcai")
	public String fengcailist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		List<Honor> list =honorService.getEntityAll();
		model.addAttribute("fclist", list);
		model.addAttribute("page", "fengcai.jsp");
		return "admin/index";
	}
	@RequestMapping("/goaddfc")
	public String goaddfengcai(Model model,HttpServletRequest request,HttpServletResponse response ){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		model.addAttribute("page", "addfengcai.jsp");
		return "admin/index";
	}
	@RequestMapping("/addfc")
	public String addfengcai(Model model,HttpServletRequest request,HttpServletResponse response,Honor fengcai ){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		fengcai.setPublish(0);
		honorService.addEntity(fengcai);
		return "redirect:fengcai";
	}
	@RequestMapping("/delfc")
	public String delfengcai(Model model,HttpServletRequest request,HttpServletResponse response,Honor fengcai ){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id =Integer.parseInt(request.getParameter("id"));
		honorService.delete(" id=:id ", id);
		return "redirect:fengcai";
	}
	@RequestMapping("/pubfc")
	public String publishfchon(Model model,HttpServletRequest request,HttpServletResponse response,Honor fengcai){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		Honor fc = honorService.getEntityByProperty(" id=:id ", id);
		fc.setId(id);
		fc.setPublish(1);
		honorService.update(fc);
		model.addAttribute("page", "fengcai.jsp");
		return "redirect:fengcai";
	}

	@RequestMapping("/gonggao")
	public String gonggaolist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		List<ZhaoPin> lists =zhaoPinService.getAllByProperty(" 1=:id  order by time", 1);
		model.addAttribute("gglist", lists);
		model.addAttribute("page", "gonggaolist.jsp");


		return "admin/index";
	}
	//��������
	@RequestMapping("/gginfo")
	public String gonggaoinfo(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id")); 
		ZhaoPin gg= zhaoPinService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("gg", gg);
		model.addAttribute("page", "gonggaoinfo.jsp");
		return "admin/index";
	}
	//��ӹ���
	@RequestMapping("/addgg")
	public String addgonggao(Model model,HttpServletRequest request,HttpServletResponse response,ZhaoPin gg){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		gg.setTitle(WebUtil.TFUFT8(gg.getTitle()));
		gg.setTime(WebUtil.TFUFT8(time));
		gg.setAdress(WebUtil.TFUFT8(gg.getAdress()));
		gg.setDeadtime(WebUtil.TFUFT8(gg.getDeadtime()));
		gg.setDemand(WebUtil.TFUFT8(gg.getDemand()));
		gg.setDuty(WebUtil.TFUFT8(gg.getDuty()));
		gg.setNature(WebUtil.TFUFT8(gg.getNature()));
		gg.setNumber(gg.getNumber());
		gg.setScope(WebUtil.TFUFT8(gg.getScope()));
		gg.setType(WebUtil.TFUFT8(gg.getType()));
		gg.setPublish(0);
		zhaoPinService.addEntity(gg);
		return "redirect:gonggao";
	}	
	//ɾ���
	@RequestMapping("/delgg")
	public String delgonggao(Model model,HttpServletRequest request,HttpServletResponse response,ZhaoPin gonggao){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id = Integer.parseInt(request.getParameter("id"));
		List<Application> list = appService.getAllByProperty(" translation_id=:translation_id ", id);
		if(list != null){
			for(int i = 0;i<list.size();i++){
				appService.delete(" translation_id=:translation_id ", list.get(i).getTranslation());
			}
		}
		zhaoPinService.delete(" id=:id ", id);
		return "redirect:gonggao";
	}
	//��ӹ���
	@RequestMapping("/goaddgg")
	public String goaddgonggao(Model model,HttpServletRequest request,HttpServletResponse response,ZhaoPin gonggao){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		model.addAttribute("page", "addgonggao.jsp");
		return "admin/index";
	}	
	//���¹���
	@RequestMapping("/goupdategg")
	public String goupdategonggao(Model model,HttpServletRequest request,HttpServletResponse response,ZhaoPin gonggao){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		ZhaoPin gg = zhaoPinService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("trans",gg);
		model.addAttribute("page", "updategonggao.jsp");
		return "admin/index";
	}
	//���¹���
	@RequestMapping("/updategg")
	public String updategonggao(Model model,HttpServletRequest request,HttpServletResponse response,ZhaoPin gg){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		gg.setTitle(WebUtil.TFUFT8(gg.getTitle()));
		gg.setTime(WebUtil.TFUFT8(time));
		gg.setAdress(WebUtil.TFUFT8(gg.getAdress()));
		gg.setDeadtime(WebUtil.TFUFT8(gg.getDeadtime()));
		gg.setDemand(WebUtil.TFUFT8(gg.getDemand()));
		gg.setDuty(WebUtil.TFUFT8(gg.getDuty()));
		gg.setNature(WebUtil.TFUFT8(gg.getNature()));
		gg.setNumber(gg.getNumber());
		gg.setScope(WebUtil.TFUFT8(gg.getScope()));
		gg.setType(WebUtil.TFUFT8(gg.getType()));
		gg.setPublish(0);
		zhaoPinService.update(gg);
		return "redirect:gginfo?id="+gg.getId();
	}
	//��������
	@RequestMapping("/pubgg")
	public String publish(Model model,HttpServletRequest request,HttpServletResponse response,ZhaoPin gonggao){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id"));
		ZhaoPin gg = zhaoPinService.getEntityByProperty(" id=:id ", id);
		gonggao.setId(id);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		gonggao.setTime(WebUtil.TFUFT8(time));
		gonggao.setTitle(WebUtil.TFUFT8(gg.getTitle()));
		gonggao.setAdress(WebUtil.TFUFT8(gg.getAdress()));
		gonggao.setDeadtime(WebUtil.TFUFT8(gg.getDeadtime()));
		gonggao.setDemand(WebUtil.TFUFT8(gg.getDemand()));
		gonggao.setDuty(WebUtil.TFUFT8(gg.getDuty()));
		gonggao.setNature(WebUtil.TFUFT8(gg.getNature()));
		gonggao.setNumber(gg.getNumber());
		gonggao.setScope(WebUtil.TFUFT8(gg.getScope()));
		gonggao.setType(WebUtil.TFUFT8(gg.getType()));
		gonggao.setPublish(1);
		zhaoPinService.update(gonggao);
		model.addAttribute("page", "gonggaolist.jsp");
		return "redirect:gonggao";
	}



	@RequestMapping("/app")
	public String applist(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		List<Application> lists =appService.getAllByProperty(" 1=:id ", 1);
		model.addAttribute("applist", lists);
		model.addAttribute("page", "applist.jsp");


		return "admin/index";
	}
	//��������
	@RequestMapping("/appinfo")
	public String appinfo(Model model,HttpServletRequest request,HttpServletResponse response){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id=Integer.parseInt(request.getParameter("id")); 
		Application gg= appService.getEntityByProperty(" id=:id ", id);
		model.addAttribute("app", gg);
		model.addAttribute("page", "appinfo.jsp");
		return "admin/index";
	}

	@RequestMapping("/delapp")
	public String delapp(Model model,HttpServletRequest request,HttpServletResponse response,Application gonggao){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		Integer id = Integer.parseInt(request.getParameter("id"));
		appService.delete(" id=:id ", id);
		return "redirect:app";
	}

	@RequestMapping(value="/uploadImg",method=RequestMethod.POST)
	@ResponseBody
	public Object addUser(@RequestParam CommonsMultipartFile files,HttpServletRequest request){  
		System.out.println("fileName---------->" + files.getOriginalFilename()); 
		String name= files.getOriginalFilename();
		String str =name.substring(name.lastIndexOf("."));
		InputStream in=null;
		if(!files.isEmpty()){  
			try {
				in= files.getInputStream();  
				String allpath= request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/common/upload/";
				String context=request.getRealPath("/");
				String imageNames=WebUtil.savefile(in,allpath,context,str); 
				return new Messages<Object>(imageNames,"上传成功",true);
			} catch (Exception e) {  
				e.printStackTrace();  
				return new Messages<Object>(null,"上传出错",false);
			}  
		} 
		return null;	            
	} 
	@RequestMapping("/xz")
	public String goxiazai(Model model,HttpServletRequest request,HttpServletResponse response ){
		Admin user = (Admin)request.getSession().getAttribute("User");
		if(user==null){
			return "redirect:login";
		}
		model.addAttribute("page", "upload.jsp");
		return "admin/index";
	}
	@RequestMapping(value="upload")
	public String upload(HttpServletRequest request,XiaZai xz){
		String filename = request.getParameter("name");
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		String time = df.format(new Date());
		xz.setTime(WebUtil.TFUFT8(time));
		xz.setTitle(xz.getTitle());
		xz.setFilename(WebUtil.TFUFT8(filename));
		xiaZaiService.addEntity(xz);
		WebUtil.init(request);
		try {
			WebUtil.upload(request);
			request.setAttribute("msg", "ok");
			request.setAttribute("map", WebUtil.getMap());

		} catch (Exception e) {
			e.printStackTrace();
		}
		return "redirect:xiazai";
	}
	@RequestMapping(value="xiazai")
	public String list(Model model,HttpServletRequest request){
		WebUtil.init(request);
		List<XiaZai> list = xiaZaiService.getAllByProperty(" 1=:id ", 1);
		model.addAttribute("list",  list);
		model.addAttribute("map",  WebUtil.getMap());
		model.addAttribute("page", "xiazai.jsp");
		return "admin/index";
	}
	@RequestMapping(value="remove")
	public String remove(Model model,HttpServletRequest request, HttpServletResponse response){
		Integer id = Integer.parseInt(request.getParameter("id"));
		xiaZaiService.delete(" id=:id ", id);
		return "redirect:xiazai";
	}
	@RequestMapping(value="download")
	public void download(HttpServletRequest request, HttpServletResponse response){
		WebUtil.init(request);
		try {
			String downloadfFileName = request.getParameter("filename");
			downloadfFileName = new String(downloadfFileName.getBytes("iso-8859-1"),"utf-8");
			String fileName = downloadfFileName.substring(downloadfFileName.indexOf("_")+1);
			String userAgent = request.getHeader("User-Agent");
			byte[] bytes = userAgent.contains("MSIE") ? fileName.getBytes() : fileName.getBytes("UTF-8"); 
			fileName = new String(bytes, "ISO-8859-1");
			response.setHeader("Content-disposition", String.format("attachment; filename=\"%s\"", fileName));
			WebUtil.download(downloadfFileName, response.getOutputStream());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
